<template>
  <div>
    <el-form ref="form" :model="formData" label-width="80px">
  <el-form-item label="文章标题">
    <el-input v-model="formData.title"></el-input>
  </el-form-item>
<el-form-item label="文章内容">
    <el-input :autosize="{minRows:5,maxRows:10}" type="textarea" v-model="formData.content"></el-input>
  </el-form-item>
  <el-form-item label="内容分布">
    <el-select v-model="formData.tip" placeholder="请选择区域">
      <el-option label="js" value="js"></el-option>
      <el-option label="node" value="node"></el-option>
      <el-option label="java" value="java"></el-option>
      <el-option label="c++" value="c++"></el-option>
      <el-option label="python" value="python"></el-option>
     
    </el-select>
  </el-form-item>
  <el-form-item label="文章作者">
    <el-input v-model="formData.author"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" :plain="true"  @click="onSubmit">立即发布</el-button>
    <el-button @click="Cancel">取消</el-button>
  </el-form-item>
   </el-form>
  </div>
</template>

<script>
import axios from 'axios';
export default {
name:'write',
data() {
  return {
    
    formData:{
      title:'',
    content:'',
    tip:'',
    author:'',
    }
  }
},
methods:{
  onSubmit(){
    // console.log(this.formData);
  axios.post('/insertPoke',{
     title:this.formData.title,
    content:this.formData.content,
    tip:this.formData.tip,
    author:this.formData.author,
  }).then(res=>{
    // console.log(res);
   this.formData.title='',
    this.formData.content='',
   this.formData.tip='',
  this.formData.author=''


  }).catch(err=>{
      console.log(err);
     })
       this.$message('发布成功！');
  },
  Cancel(){
    this.formData.title='',
    this.formData.content='',
   this.formData.tip='',
  this.formData.author=''
  }
}
}
</script>

<style>

</style>